<template>
  <router-layout>
    <div class="setting-box">
      <div class="other-setting">
        <van-cell-group>
          <van-cell icon="manager-o" title="个人信息"/>
          <van-cell icon="setting-o" title="通用"/>
          <van-cell icon="warn-o" title="隐私"/>
        </van-cell-group>
      </div>
      <div class="out-btn">
        <van-button size="large" @click="goOut">退出登录</van-button>
      </div>
    </div>
  </router-layout>
</template>

<script>
import { get_logout } from "@/api/login";
import { getToken, removeToken } from "@/utils/auth";

export default {
  methods: {
    // 退出登录
    goOut() {
      this.$dialog
        .confirm({
          message: "您确定要退出登录吗?退出需要重新登录"
        })
        .then(() => {
          this.get_out();
        })
        .catch(() => {});
    },
    async get_out() {
      let status = {
        sysStatus:localStorage.getItem("sysStatus")
      }
      let { data } = await get_logout(status);
      if (data.status == 100) {
        //  window.localStorage.clear()
        window.localStorage.removeItem("companyId");
        window.localStorage.removeItem("person");
        // window.localStorage.removeItem("user");
        // window.localStorage.removeItem("company");
        window.localStorage.removeItem("token");
        removeToken();
        this.$toast("退出登录成功");
        // this.$router.replace("/Login");
        this.$router.push({
          path:"/Login",
          query:{name:'layout'}
        })
      }
    }

  },
  created() {
    
  }
};
</script>

<style lang="scss" scoped>
.out-btn {
  margin-top: 10px;
  .van-button__text {
    color: #f44;
  }
}
</style>

